package a.h;

import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;

class mb
{
  private JPopupMenu a;
  private Object[] b;
  private mc c;
  private String d;
  private JComponent e;
  private String f;
  private boolean g = true;
  private JFileChooser h;
  private Collection i = new ArrayList();
  
  public JPopupMenu a()
  {
    return this.a;
  }
  
  public JFileChooser b()
  {
    return this.h;
  }
  
  public mb(mc parammc, JComponent paramJComponent, Rectangle paramRectangle, ob paramob)
  {
    this.c = parammc;
    this.b = parammc.b().a().toArray();
    if (j == 0)
    {
      if (paramob == null)
      {
        this.d = dc.a().b("IMAGE_OPTION_ITEM.BROWSE");
        this.f = dc.a().b("IMAGE_OPTION_ITEM.NO_IMAGE");
        if (j != 0) {
          break label196;
        }
        if (!ec.s) {}
      }
      else
      {
        this.d = paramob.b("IMAGE_OPTION_ITEM.BROWSE");
        this.f = paramob.b("IMAGE_OPTION_ITEM.NO_IMAGE");
      }
    }
    else
    {
      if (j == 0) {
        if ("IMAGE_OPTION_ITEM.BROWSE".equals(this.d)) {
          this.d = dc.a().b("IMAGE_OPTION_ITEM.BROWSE");
        }
      }
      if ("IMAGE_OPTION_ITEM.NO_COLOR".equals(this.f)) {
        this.f = dc.a().b("IMAGE_OPTION_ITEM.NO_COLOR");
      }
    }
    this.e = paramJComponent;
    this.h = new JFileChooser();
    label196:
    ud localud = new ud();
    this.h.addChoosableFileFilter(localud);
    this.h.setFileFilter(localud);
    a(paramRectangle);
  }
  
  private void a(Rectangle paramRectangle)
  {
    int m = ec.t;
    this.a = new JPopupMenu();
    JList localJList = new JList(this.b);
    ListCellRenderer localListCellRenderer = (ListCellRenderer)this.c.c("ImageOptionItem.renderer");
    if (m == 0)
    {
      if (localListCellRenderer != null)
      {
        localJList.setCellRenderer(localListCellRenderer);
        if (m != 0) {
          break label155;
        }
        if ((localListCellRenderer instanceof sb))
        {
          localObject = (sb)localListCellRenderer;
          double d1 = paramRectangle.getWidth();
          int j = ((sb)localObject).a;
          int k = (int)(d1 / j);
          localJList.setVisibleRowCount((int)Math.ceil(this.b.length / k));
          localJList.setLayoutOrientation(2);
        }
      }
      this.a.setBackground(Color.WHITE);
      localJList.setSelectionMode(0);
      localJList.setBackground(Color.WHITE);
      localJList.setOpaque(false);
      this.a.add(localJList);
    }
    label155:
    Object localObject = new AbstractAction(this.d)
    {
      public void actionPerformed(ActionEvent paramAnonymousActionEvent)
      {
        mb.this.a(mb.this.a);
      }
    };
    Boolean localBoolean1 = (Boolean)this.c.c("ImageOptionItem.allowBrowse");
    if (m == 0) {
      if (localBoolean1.booleanValue())
      {
        this.a.addSeparator();
        this.a.add((Action)localObject);
      }
    }
    Boolean localBoolean2 = (Boolean)this.c.c("ImageOptionItem.allowEmptyImage");
    if (m == 0)
    {
      if (localBoolean2.booleanValue())
      {
        this.a.addSeparator();
        this.a.add(new AbstractAction(this.f)
        {
          public void actionPerformed(ActionEvent paramAnonymousActionEvent)
          {
            mb.this.g = false;
            mb.this.a(new ed(null, null));
          }
        });
      }
      localJList.addMouseListener(new MouseAdapter()
      {
        private final JList val$imgList;
        
        public void mouseClicked(MouseEvent paramAnonymousMouseEvent)
        {
          int i = this.val$imgList.locationToIndex(paramAnonymousMouseEvent.getPoint());
          Object localObject = mb.this.b[i];
          mb.this.g = false;
          mb.this.a(localObject);
        }
      });
      localJList.addMouseMotionListener(new MouseMotionAdapter()
      {
        private final JList val$imgList;
        
        public void mouseMoved(MouseEvent paramAnonymousMouseEvent)
        {
          int i = this.val$imgList.locationToIndex(paramAnonymousMouseEvent.getPoint());
          this.val$imgList.setSelectedIndex(i);
        }
      });
      this.a.addPopupMenuListener(new PopupMenuListener()
      {
        public void popupMenuCanceled(PopupMenuEvent paramAnonymousPopupMenuEvent)
        {
          mb.this.g = true;
          mb.this.c();
        }
        
        public void popupMenuWillBecomeInvisible(PopupMenuEvent paramAnonymousPopupMenuEvent)
        {
          if ((ec.t != 0) || (mb.this.g)) {
            mb.this.c();
          }
        }
        
        public void popupMenuWillBecomeVisible(PopupMenuEvent paramAnonymousPopupMenuEvent)
        {
          mb.this.g = true;
        }
      });
    }
  }
  
  public void a(JPopupMenu paramJPopupMenu)
  {
    int j = ec.t;
    if (j == 0) {
      if (this.h.showOpenDialog(JOptionPane.getFrameForComponent(this.e)) == 0)
      {
        try
        {
          URL localURL = this.h.getSelectedFile().toURL();
          BufferedImage localBufferedImage = ImageIO.read(localURL);
          this.g = false;
          a(new ed(localBufferedImage, localURL));
        }
        catch (MalformedURLException localMalformedURLException)
        {
          this.g = true;
          c();
        }
        catch (IOException localIOException)
        {
          this.g = true;
          c();
          if (j != 0) {
            break label103;
          }
        }
        if (!ec.s) {
          return;
        }
      }
      else
      {
        this.g = true;
      }
    }
    label103:
    c();
  }
  
  public void a(Object paramObject)
  {
    int k = ec.t;
    boolean bool = ec.s;
    if ((k != 0) || (!this.i.isEmpty()))
    {
      b_[] arrayOfb_ = new b_[this.i.size()];
      this.i.toArray(arrayOfb_);
      int j = 0;
      do
      {
        if (j >= arrayOfb_.length) {
          break;
        }
        arrayOfb_[j].a(this.a, paramObject);
        j++;
      } while (!bool);
    }
  }
  
  public void c()
  {
    int k = ec.t;
    boolean bool = ec.s;
    if ((k != 0) || (!this.i.isEmpty()))
    {
      b_[] arrayOfb_ = new b_[this.i.size()];
      this.i.toArray(arrayOfb_);
      int j = 0;
      do
      {
        if (j >= arrayOfb_.length) {
          break;
        }
        arrayOfb_[j].a();
        j++;
      } while (!bool);
    }
  }
  
  public void a(b_ paramb_)
  {
    this.i.add(paramb_);
  }
  
  static abstract interface b_
  {
    public abstract void a(JPopupMenu paramJPopupMenu, Object paramObject);
    
    public abstract void a();
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.h.mb

 * JD-Core Version:    0.7.0.1

 */